/**
 * 
 */
package com.coder520.sync_learning.demo;

import java.util.concurrent.TimeUnit;

import com.coder520.sync_learning.demo.SyncDemo.maipiao;

/**
 * @author zhaoyibo
 *
 */
public class ThreadGroupBasic {
	public static void main(String[] args) throws InterruptedException {
		
		ThreadGroup group=new ThreadGroup("group1");
		Thread thread=new Thread(group,()-> {
			while(true) {
				try {
					TimeUnit.SECONDS.sleep(1);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		},"thread1");
		
		thread.setDaemon(true);
		thread.start();
		
		group.setMaxPriority(3);
		
		//确保线程已经启动
		TimeUnit.MILLISECONDS.sleep(1);
		
		ThreadGroup mainGroup=Thread.currentThread().getThreadGroup();
		
		System.out.println("activeCount="+mainGroup.activeCount());
		System.out.println("activeGroupCount="+mainGroup.activeGroupCount());
		System.out.println("getMaxPriority="+mainGroup.getMaxPriority());
		System.out.println("getName="+mainGroup.getName());
		System.out.println("getParent="+mainGroup.getParent());
		mainGroup.list();
		System.out.println("--------------------------------------");
		System.out.println("parentOf="+mainGroup.parentOf(group));
		 System.out.println("parentOf= "+mainGroup.parentOf(mainGroup));
	}
}
